package com.yidu.king.service.impl;

import com.yidu.king.controller.vo.PersonFeiziVo;
import com.yidu.king.dao.PersonFeiziMapper;
import com.yidu.king.domain.PersonFeizi;
import com.yidu.king.service.PersonFeiziService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;

/**
 * <p>@Description: No Description</p>
 * <p>@Author yidu-liandyao</p>
 * <p>@Date: 2021-01-13</p>
 * <p>@Time: 15:59</p>
 */
@Service
public class PersonFeiziServiceImpl implements PersonFeiziService {

    @Resource
    PersonFeiziMapper personFeiziMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return personFeiziMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(PersonFeizi record) {
        return personFeiziMapper.insert(record);
    }

    @Override
    public int insertSelective(PersonFeiziVo vo) {
        PersonFeizi po = new PersonFeizi();
        BeanUtils.copyProperties(vo,po);
        if(!StringUtils.isEmpty(vo.getBirthday_())) {
            po.setBirthday(Date.valueOf(vo.getBirthday_()));
        }
        return personFeiziMapper.insertSelective(po);
    }

    @Override
    public PersonFeiziVo selectByPrimaryKey(Integer id) {
        return personFeiziMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(PersonFeiziVo vo) {
        PersonFeizi po = new PersonFeizi();
        BeanUtils.copyProperties(vo,po);
        if(!StringUtils.isEmpty(vo.getBirthday_())) {
            po.setBirthday(Date.valueOf(vo.getBirthday_()));
        }
        return personFeiziMapper.updateByPrimaryKeySelective(po);
    }

    @Override
    public int updateByPrimaryKey(PersonFeizi record) {
        return personFeiziMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<PersonFeiziVo> selectAll(PersonFeiziVo vo) {
        return personFeiziMapper.selectAll(vo);
    }

    @Override
    public int selectCount(PersonFeiziVo vo) {
        return personFeiziMapper.selectCount(vo);
    }
}
